//
//  IGDrawingsCollectionCell.m
//  jingdongfang
//
//  Created by boectoswteam on 2018/5/10.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "IGDrawingsCollectionCell.h"

@interface IGDrawingsCollectionCell()
{
    UIView *titleBackgroundV;
}
@end

@implementation IGDrawingsCollectionCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
    }
    return self;
}

-(void)creatUI{
    self.imageV = [[UIImageView alloc]init];
    self.imageV.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.imageV];
    
    titleBackgroundV = [[UIView alloc]init];
    titleBackgroundV.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"B-16-2"]];
    [self.imageV addSubview:titleBackgroundV];
    
    self.titleL = [[UILabel alloc]init];
    self.titleL.text = @"作品名称";
    self.titleL.textColor = [UIColor whiteColor];
    self.titleL.font = [UIFont font14];
    [titleBackgroundV addSubview:self.titleL];
}

-(void)layoutSubviews{
    [super layoutSubviews];

    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.top.mas_equalTo(self.mas_top).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
    }];

    [titleBackgroundV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.imageV.mas_left).offset(0);
        make.height.equalTo(@31);
        make.bottom.equalTo(self.imageV.mas_bottom).offset(0);
        make.width.equalTo(self.imageV.mas_width).offset(0);
    }];
    
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleBackgroundV.mas_left).offset(10);
        make.top.mas_equalTo(titleBackgroundV.mas_top).offset(7.5);
        make.width.mas_equalTo(self.width - 15);
        make.height.mas_equalTo(13.5);
    }];
}

-(void)setData:(IGActivityDetailSingleModel *)data{
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:data.image]];
    self.titleL.text = data.title!=nil?data.title:@"";
}

@end
